<?php

namespace App\Models;

class Order extends Model
{
    protected $fillable = [
        'field_name',
    ];
    protected $table = 'order';
    protected $orderSourceType = [1=>'携程',2=>'飞猪',3=>'美团',4=>'去哪儿'];
    protected $orderType = [1=>'已预定',2=>'已入住',3=>'已退房',4=>'已取消'];
    protected $certificateType = [1=>'身份证',2=>'永久居住证',3=>'护照'];
    //1已预定2已入住3已退房4已取消'

    public function getOrderSourceTypeAttribute($value)
    {
        return isset($this->orderSourceType[$value]) ? $this->orderSourceType[$value] : reset($this->orderSourceType);
    }
    public function getCertificateTypeAttribute($value)
    {
        return isset($this->certificateType[$value]) ? $this->certificateType[$value] : reset($this->certificateType);
    }

    public function getOrderTypeAttribute($value)
    {
        return isset($this->orderType[$value]) ? $this->orderType[$value] : reset($this->orderType);
    }

    public function user()
    {
        return $this->hasOne(AppUser::class,'id','user_id');
    }

    public function housings()
    {
        return $this->hasOne(Housings::class,'id','housings_id');
    }

    public function enterlog()
    {
        return $this->hasOne(EnterLog::class,'id','enter_log_id');
    }
}
